//
//  ZLPullMenuConfig.swift
//  ZLPullMenuSwift
//
//  Created by 科大 on 2025/1/16.
//

import UIKit

/// 父类
public class ZLPullMenuBaseConfig {
    /// 字体
    public var font: UIFont
    
    /// 字色
    public var textColor: UIColor
    
    public init(font: UIFont, textColor: UIColor) {
        self.font = font
        self.textColor = textColor
    }
    
    /// 默认配置
    public class func defaultConfig() -> ZLPullMenuBaseConfig {
        return ZLPullMenuBaseConfig(
            font: .systemFont(ofSize: 14),
            textColor: .black
        )
    }
    
    public class func config(font: UIFont, textColor: UIColor) -> ZLPullMenuBaseConfig {
        return ZLPullMenuBaseConfig(font: font, textColor: textColor)
    }
}

/// 顶部菜单配置
public class ZLPullMenuConfig: ZLPullMenuBaseConfig {
    /// 选中字体
    public var selectedFont: UIFont
    
    /// 选中字色
    public var textSelectedColor: UIColor
    
    /// 箭头颜色（下）
    public var arrowColor: UIColor
    
    /// 选中箭头色（上）
    public var arrowSelectedColor: UIColor
    
    public init(font: UIFont,
                selectedFont: UIFont,
                textColor: UIColor,
                textSelectedColor: UIColor,
                arrowColor: UIColor,
                arrowSelectedColor: UIColor) {
        self.selectedFont = selectedFont
        self.textSelectedColor = textSelectedColor
        self.arrowColor = arrowColor
        self.arrowSelectedColor = arrowSelectedColor
        super.init(font: font, textColor: textColor)
    }
    
    public class func config(font: UIFont,
                             selectedFont: UIFont,
                             textColor: UIColor,
                             textSelectedColor: UIColor,
                             arrowColor: UIColor,
                             arrowSelectedColor: UIColor) -> ZLPullMenuConfig {
        return ZLPullMenuConfig(
            font: font,
            selectedFont: selectedFont,
            textColor: textColor,
            textSelectedColor: textSelectedColor,
            arrowColor: arrowColor,
            arrowSelectedColor: arrowSelectedColor
        )
    }
    
    public override class func defaultConfig() -> ZLPullMenuBaseConfig {
        return config(
            font: .systemFont(ofSize: 14),
            selectedFont: .systemFont(ofSize: 14, weight: .bold),
            textColor: UIColor(white: 0.4, alpha: 1),
            textSelectedColor: UIColor(white: 0.15, alpha: 1),
            arrowColor: UIColor(white: 0.4, alpha: 1),
            arrowSelectedColor: UIColor(white: 0.15, alpha: 1)
        )
    }
}

/// 组标题配置
public class ZLPullMenuGroupConfig: ZLPullMenuBaseConfig {
    public override class func config(font: UIFont, textColor: UIColor) -> ZLPullMenuGroupConfig {
        return ZLPullMenuGroupConfig(font: font, textColor: textColor)
    }
    
    public override class func defaultConfig() -> ZLPullMenuBaseConfig {
        return config(
            font: .systemFont(ofSize: 14, weight: .bold),
            textColor: .black
        )
    }
}

/// 选项配置
public class ZLPullMenuOptionConfig: ZLPullMenuBaseConfig {
    /// 选中字体
    public var selectedFont: UIFont
    
    /// 选中字色
    public var textSelectedColor: UIColor
    
    /// 背景色
    public var backgroundColor: UIColor
    
    /// 选中背景色
    public var backgroundSelectedColor: UIColor
    
    /// 边框色
    public var borderColor: UIColor
    
    /// 选中边框色
    public var borderSelectedColor: UIColor
    
    public init(font: UIFont,
                selectedFont: UIFont,
                textColor: UIColor,
                textSelectedColor: UIColor,
                backgroundColor: UIColor,
                backgroundSelectedColor: UIColor,
                borderColor: UIColor,
                borderSelectedColor: UIColor) {
        self.selectedFont = selectedFont
        self.textSelectedColor = textSelectedColor
        self.backgroundColor = backgroundColor
        self.backgroundSelectedColor = backgroundSelectedColor
        self.borderColor = borderColor
        self.borderSelectedColor = borderSelectedColor
        super.init(font: font, textColor: textColor)
    }
    
    public class func config(font: UIFont,
                             selectedFont: UIFont,
                             textColor: UIColor,
                             textSelectedColor: UIColor,
                             backgroundColor: UIColor,
                             backgroundSelectedColor: UIColor,
                             borderColor: UIColor,
                             borderSelectedColor: UIColor) -> ZLPullMenuOptionConfig {
        return ZLPullMenuOptionConfig(
            font: font,
            selectedFont: selectedFont,
            textColor: textColor,
            textSelectedColor: textSelectedColor,
            backgroundColor: backgroundColor,
            backgroundSelectedColor: backgroundSelectedColor,
            borderColor: borderColor,
            borderSelectedColor: borderSelectedColor
        )
    }
    
    public override class func defaultConfig() -> ZLPullMenuBaseConfig {
        return config(
            font: .systemFont(ofSize: 13),
            selectedFont: .systemFont(ofSize: 13),
            textColor: UIColor(red: 0.29, green: 0.29, blue: 0.29, alpha: 1.00),
            textSelectedColor: .black,
            backgroundColor: UIColor(red: 0.97, green: 0.96, blue: 0.96, alpha: 1.00),
            backgroundSelectedColor: UIColor(red: 0.97, green: 0.96, blue: 0.96, alpha: 1.00),
            borderColor: .clear,
            borderSelectedColor: .black
        )
    }
}
